package com.entrogy.controller;

import com.entrogy.bean.ProvinceEntity;
import com.entrogy.service.ProvinceService;
import com.entrogy.utils.ApiReturnUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Api(description = "省市区的操作接口")
@RestController
@RequestMapping(value = "/provincecontroller")
public class ProvinceController {
    private static final Logger logger = LoggerFactory.getLogger(ProvinceController.class);
	@Autowired
	private ProvinceService provinceService ;

	//根据省会的ID 查询出其所有的市区
	@ApiOperation(value = "根据根ID查询出所有的市区或根据市区ID查出所有的省会或根据省会的ID 查询出其所有的市区")
	@ApiImplicitParams({
			@ApiImplicitParam(name="provinceId",value="省会的code值",dataType="int", paramType = "query",required = true)
	})
	@RequestMapping(value = "/getcitybyprovince",method = RequestMethod.GET)
	public Map<String, Object> getCityByProvince(int provinceId){
		List<ProvinceEntity> provinceEntity = provinceService.getCityByProvince(provinceId);
		return ApiReturnUtil.success("获取成功",provinceEntity);
	}

}
